<!-- S search -->
<app-search-bar
  [submitLoading]="tableParams.loading"
  [searchOptions]="searchOptions"
  labelFlex="90px"
  (onSearch)="queryResetData($event)"
  (onReset)="queryResetData($event)"
>
</app-search-bar>
<!-- E search -->

<nz-card class="m-t-4">
  <div class="pagination-wrap-position table-wrap">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      [nzScroll]="{ x: '1100px' }"
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.loading"
      [nzData]="tableParams.tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center" nzWidth="200px" nzLeft>售后单号</th>
          <th nzAlign="center" nzWidth="150px">售后状态</th>
          <th nzAlign="center" nzWidth="150px">售后方式</th>
          <th nzAlign="center" nzWidth="120px">退款金额</th>
          <th nzAlign="center" nzWidth="120px">订单金额</th>
          <th nzAlign="center" nzWidth="200px">订单编号</th>
          <th nzAlign="center" nzWidth="186px">客户</th>
          <th nzAlign="center" nzWidth="170px">申请时间</th>
          <th nzAlign="center" nzWidth="200px">物流单号</th>
          <th nzAlign="center" nzWidth="170px">退款时间</th>
          <th nzAlign="center" nzWidth="160px" nzRight>操作</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <!-- 售后单号 -->
          <td nzAlign="center" nzLeft>{{ data.returnNum || '-' }}</td>
          <!-- 售后状态 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': data.status | secondSaleAfterStatus: 'color'}">
              {{ data.status | secondSaleAfterStatus: 'label' }}
            </span>
          </td>
          <!-- 售后方式 -->
          <td nzAlign="center">
            {{ data.type | secondSaleAfterMode: 'label' }}
          </td>
          <!-- 退款金额 -->
          <td nzAlign="center">
            <p>￥{{ data.refundPrice || '-' }}</p>
            <p>爱豆{{ data.refundAiDouAmount || '0' }}</p>
          </td>
          <!-- 订单金额 -->
          <td nzAlign="center">
            <p>￥{{ data.realPrice || '-' }}</p>
            <p>爱豆{{ data.aiDouAmount || '0' }}</p>
          </td>
          <!-- 订单编号 -->
          <td nzAlign="center">
            <a
              style="color: #1890ff;"
              target="_blank"
              routerLink="/used-store/usedOrderDetails"
              [queryParams]="{id: data?.orderId}"
            >
              {{ data.orderNum || '-' }}
            </a>
          </td>
          <!-- 客户 -->
          <td nzAlign="center">
            {{ data.customerName ? data.customerName + '：' : '-' }}
            {{ data.customerPhone || '-' }}
          </td>
          <!-- 申请时间 -->
          <td nzAlign="center">{{ data.createTime || '-' }}</td>
          <!-- 物流单号 -->
          <td nzAlign="center">{{ data.expressNum || '-' }}</td>
          <!-- 退款时间 -->
          <td nzAlign="center">{{ data.refundTime || '-' }}</td>
          <!-- 操作 -->
          <td nzAlign="center" nzRight>
            <button
              nz-button
              nzType="link"
              nzSize="small"
              (click)="followModal(data)"
            >跟进</button>

            <button
              nz-button
              nzType="link"
              nzSize="small"
              [routerLink]="['/used-store/used-after-sales-detatils']"
              [queryParams]="{id: data.refundId}"
            >查看</button>
          </td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
  </div>
</nz-card>

<!-- 跟进Component -->
<app-follow-up #followUpRef [initParams]="initParams" [ohterParams]="{ type: 1 }"></app-follow-up>